<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<link rel="stylesheet" href="/css/font.css">
<link rel="stylesheet" href="/css/xadmin.css">
<script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
<script src="/lib/layui/layui.js" charset="utf-8"></script>
<script type="text/javascript" src="/js/xadmin.js"></script>
<script src="/layui/layui.js" charset="utf-8"></script>
<style>

    .layui-form-label{
        width:100px
    }
    .layui-input-block{
        margin-left: 130px;
        min-height: 30px;
    }
</style>

<div id="modalAdd" class="modal fade bs-example-modal-xs" tabindex="-1"
     role="dialog" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-body">
                <form class="layui-form">
                    <div class="layui-form-item">
                        <label for="staffName" class="layui-form-label">
                            <span class="x-red">*</span>姓名
                        </label>
                        <div class="layui-input-inline">
                            <input type="text"  id="staffName" name="staffName"  required="" lay-verify="required"
                                   autocomplete="off" class="layui-input" placeholder="姓名">
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label for="staffUsername" class="layui-form-label">
                            <span class="x-red">*</span>用户名
                        </label>
                        <div class="layui-input-inline">
                            <input type="text"  id="staffUsername" name="staffUsername" required="" lay-verify="required"
                                   autocomplete="off" class="layui-input" placeholder="用户名">
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label for="staffPwd" class="layui-form-label">
                            <span class="x-red">*</span>密码
                        </label>
                        <div class="layui-input-inline">
                            <input type="password"  id="staffPwd" name="staffPwd" minlength="6" required="" lay-verify="staffPwd"
                                   autocomplete="off" class="layui-input" placeholder="密码">
                        </div>
                    </div>


                    <div class="layui-form-item">
                        <label for="staffTel" class="layui-form-label">
                            <span class="x-red">*</span>电话
                        </label>
                        <div class="layui-input-inline">
                            <input type="text"  id="staffTel"name="staffTel" maxlength="11" onblur="limitPhone(this.value)" oninput = "value=value.replace(/[^\d]/g,'')"
                                   required="" lay-verify="phone" autocomplete="off" class="layui-input" placeholder="电话">
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label for="staffAddr" class="layui-form-label">
                            <span class="x-red">*</span>地址
                        </label>
                        <div class="layui-input-inline">
                            <input type="text"  id="staffAddr" name="staffAddr" required="" lay-verify="required"
                                   autocomplete="off" class="layui-input" placeholder="xx省xx市">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <button  class="layui-btn" lay-filter="add" lay-submit="">
                            保存
                        </button>
                    </div>
                </form>

            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button>
                <button id="addModalSubmit" type="button" class="btn btn-primary">提交</button>
            </div>

        </div>
    </div>
</div>
<script>
    //form表单,layer弹出框
    layui.use(['form','layer'],function () {
        $ = layui.jquery;
        var form = layui.form, layer = layui.layer;

        //新增按钮
        form.on('submit(add)', function (data) {
            console.log(data);

            $.ajax({
                url: "/staff/submitAdd",
                async: false,
                type: "POST",
                dataType: "json",
                data: data.field,
                success:function (data) {
                    //提示信息
                    layer.alert(data.info);
                    //放入了map中，调用info
                    if (data.info=="新增用户成功！"){
                        //获得frame索引
                        var index = parent.layer.getFrameIndex(window.name);
                        //关闭当前frame
                        parent.layer.close(index);
                        //刷新
                        parent.window.location.replace("/Table/staffInfosTable")
                    }
                }

            })
            return false;
        });
    })
</script>
<script src="/static/build/layui.js"></script>

<script>
    layui.use('laydate', function(){
        var laydate = layui.laydate;

        //执行一个laydate实例
        laydate.render({
            elem: '#userBirth' //指定元素
        });
    });
</script>
<script>
    //form表单,layer弹出框
    layui.use(['form','layer'],function () {
        $ = layui.jquery;
        var form = layui.form, layer = layui.layer;

        //新增按钮
        form.on('submit(add)', function (data) {
            console.log(data);

            $.ajax({
                url: "/user/add",
                async: false,
                type: "POST",
                dataType: "json",
                data: data.field,
                success: function (data) {
                    //提示信息
                    layer.alert(data.info);
                    //放入了map中，调用info
                    if (rs.status == 200"){
                    //获得frame索引
                    var index = parent.layer.getFrameIndex(window.name);
                    //关闭当前frame
                    parent.layer.close(index);
                    //刷新
                    parent.window.location.replace("/staffInfo/t")
                }
            })

        })

        return false;
    })
    }
    layui.use('laydate', function(){
        var laydate = layui.laydate;

        //自定义日期格式
        laydate.render({
            elem: '#inputTime'
            ,format: 'yyyy-MM-dd HH:mm:ss' //可任意组合
        });
</script>